package com.zzp.controller;

import com.zzp.message.WebsocketMessage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/message")
@RequiredArgsConstructor
public class MessageController {

    private final WebsocketMessage websocketMessage;

    @RequestMapping("/send")
    public String sendMessage() {
        //发送广播消息
        websocketMessage.sendBroadcast("Hello, 大家好!");

        //发送个人消息
        websocketMessage.sendToUser("zzp", "Hello, zzp!");
        return "Message sent successfully!";
    }
}
